<?php


namespace App\Http\Middleware;


use Closure;
use Illuminate\Http\Request;

/**
 * 跨域控制
 * Class AppVersion
 * @package App\Http\Middleware
 */
class CrossDomain
{
    /**
     * @param Request $request
     * @param Closure $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        header('Allow: GET, HEAD, POST, PUT, PATCH, DELETE', false);
        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Headers: Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN,token, version');
        header('Access-Control-Expose-Headers: Authorization, authenticated');
        header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, OPTIONS');
        header('Access-Control-Allow-Credentials: true');
        return $next($request);
    }
}
